package gew.data;

import java.util.ArrayList;

public class TradeTopNPartnersData {

    private final ArrayList<TradeTopNPartnersDataRow> rows = new ArrayList<>();
    private final ArrayList<Integer> colIds = new ArrayList<>();
    private TradeTopNPartnersDataRow lastRow = null;
    
    public void addRow(TradeTopNPartnersDataRow row) {
        this.rows.add(row);
    }
    
    public void addDataItem(TradeTopNPartnersDataItem item) {
        if (lastRow == null || lastRow.getPeriodId() != item.getPeriodId()) {
            lastRow = new TradeTopNPartnersDataRow(item.getPeriodId());
            rows.add(lastRow);
        }
        lastRow.addItem(item);
    }
    
    public void addCol(Integer countryId) {
        if (!colIds.contains(countryId)) {
            colIds.add(countryId);
        }
    }

    public ArrayList<Integer> getColIds() {
        return colIds;
    }

    public ArrayList<TradeTopNPartnersDataRow> getRows() {
        return rows;
    }    
    
}
